﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TestUp.Models.TestWorkers.TestsModel;

namespace TestUp.Models.TestWorkers
{
    public class CheckTestProxy
    {
        public static int CheckTest(TestData testData)
        {
            int resultCounter = 0;
            foreach (var testQuestion in testData.Questions)
            {
                if (CheckTestQuestion(testQuestion))
                    resultCounter++;
            }
            return resultCounter;
        }

        public static bool CheckTestQuestion(TestQuestion testQuestion)
        {
            switch (testQuestion.TestType)
            {
                case TestTypes.CheckTest:
                    var checkTest = testQuestion as CheckTest;
                    if (checkTest != null)
                        return checkTest.Check(checkTest.Statements);
                    break;

                case TestTypes.RadioTest:
                    var radioTest = testQuestion as RadioTest;
                    if (radioTest != null)
                        return radioTest.Check(radioTest.Answer);
                    break;

                case TestTypes.EsseTest:
                    break;
                case TestTypes.MatchTest:
                    break;
                case TestTypes.InputTest:
                    break;
                case TestTypes.FillTest:
                    break;
            }
            return false;
        }
    }
}